package com.xujianlong.gmalllogger.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//@Controller
@Slf4j
@RestController
public class LoggerController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @RequestMapping("test")
   // @ResponseBody
    public String test(){
        return "su";
    }

    @RequestMapping("test2")
    public String test2(@RequestParam("name") String name, @RequestParam(value = "pwd",defaultValue = "18") String pwd ){
        System.out.println(name+" " +pwd);
        return "su";
    }
    @RequestMapping("applog")
    public String getLogger(@RequestParam("param") String jsonStr){

        //落盘
        log.info(jsonStr);
        //Logger logger = LoggerFactory.getLogger(LoggerController.class);
        //logger.info(jsonStr);

        //写入kafka
        kafkaTemplate.send("ods_base_log",jsonStr);
        return "success";
    }


}
